package edu.pku.hawk.controller.util;

import java.util.ArrayList;


public class MQHelper {

	public static void main(String[] args) {
		clearQueue();
	}

	public static void clearQueue() {
		try {
			MQManager mgr = new MQManager(Constants.MQServer_Name, Constants.MQServer_Password,
					Constants.MQServer_URL);

			System.out.println("Clear queues ...");

			ArrayList<Integer> sum = new ArrayList<Integer>();
			for (Integer i : sum)
				i = 0;
//			sum.add(mgr.getConsumerQueue(Constants.Figure_Monitor_Client_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Figure_ROW_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Figure_ROW_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Infrared_Monitor_Client_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Infrared_ROW_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Metal_Monitor_Client_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Metal_ROW_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Pressure_Monitor_Client_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Pressure_ROW_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Smoke_ROW_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Smoke_Monitor_Client_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Sound_Monitor_Client_QueueName).clear());
//			sum.add(mgr.getConsumerQueue(Constants.Sound_ROW_QueueName).clear());
			sum.add(mgr.getConsumerQueue(Constants.Ctrl_UI_Battlefield_QueueName).clear());
			sum.add(mgr.getConsumerQueue(Constants.Ctrl_UI_Path_QueueName).clear());
			sum.add(mgr.getConsumerQueue(Constants.Ctrl_UI_Proc_QueueName).clear());
			sum.add(mgr.getConsumerQueue(Constants.Ctrl_UI_Sensor_QueueName).clear());

			for (int i = 0; i < sum.size(); i++) {
				System.out.print(sum.get(i) + " ");
			}
			System.out.println("Clear down. (" + sum + " messages cleared)");

			mgr.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
